package com.my.chapter10;


public class practice16 {
    public static void cycleMove(CycleFactory factory){
        Cycle c = factory.getCycle();
        c.move();
    }

    public static void main(String[] args) {
        cycleMove(Unicycle.factory);
        cycleMove(Bicycle.factory);
        cycleMove(Tricycle.factory);
    }
}

interface Cycle{
    void move();
}

interface CycleFactory{
    Cycle getCycle();
}

class Unicycle implements Cycle{
    private Unicycle(){}

    @Override
    public void move() {
        System.out.println("Unicycle.move()");
    }

    public static CycleFactory factory = new CycleFactory() {
        @Override
        public Cycle getCycle() {
            return new Unicycle();
        }
    };
}

class Bicycle implements Cycle{
    private Bicycle(){}

    @Override
    public void move() {
        System.out.println("Bicycle.move()");
    }

    public static CycleFactory factory = new CycleFactory() {
        @Override
        public Cycle getCycle() {
            return new Bicycle();
        }
    };
}

class Tricycle implements Cycle{
    private Tricycle(){}

    @Override
    public void move() {
        System.out.println("Tricycle.move()");
    }

    public static CycleFactory factory = new CycleFactory() {
        @Override
        public Cycle getCycle() {
            return new Tricycle();
        }
    };
}